#include "typedef.h"
#include "os_sys.h"
#include "timer.h"
#include "display_driver.h"
#include "display_bsp.h"




struct DISPLAY_TASK_S
{
	SysTick_t tick;

};

struct DISPLAY_TASK_S display_task={0};



/**********************************************************************/
u32 display_test=0;
u32 display_data=0;
static void display_run(void)
{
	if(0 == systick_get_difference_assign(&display_task.tick, Tnms(97)))
		return;
	switch(display_test)
	{
		case 0x01:
			display_hight_voltage_show(display_data);
		break;
		case 0x02:
			display_hight_current_show(display_data);
		break;
		case 0x03:
			display_hight_voltage_blink_all(display_data);
		break;
		case 0x04:
			display_hight_current_blink_all(display_data);
		break;
	}
	display_test=0;
}
static void display_main_run(void)
{
	switch(sys_task_state_get(TASKID_DISPLAY ))
	{
		case TASK_STAT_FREE:
		case TASK_STAT_POWER_ON:
		case TASK_STAT_INITIAL:
			sys_task_state_set(TASKID_DISPLAY,TASK_STAT_RUN);
		break;
		case TASK_STAT_RUN:
			display_run();
		break;
		case TASK_STAT_UNINITIAL:
			sys_task_state_set(TASKID_DISPLAY,TASK_STAT_POWER_OFF);
		break;
		case TASK_STAT_POWER_OFF:
		case TASK_STAT_SLEEP:

		break;
		default:
			sys_task_state_set(TASKID_DISPLAY,TASK_STAT_POWER_ON);
		break;
	}
}
static void display_peripheral_sleep(void)
{}


static void display_message_process(E_DATAID DatID, const unsigned int  data)
{
	switch(DatID)
	{
		default:
		break;
	}
}

static void display_variable_init(void)
{
	display_bsp_init();

	display_hight_voltage_show(34);
	display_hight_current_show(1000);

}

static void display_task_tick(void)
{

}

//CONSTRUCTOR_DEFAUTL()
void display_TaskCreate(void)
{
	struct task_s task = TASK_DEFAULT_INIT();

	task.ID 		= TASKID_DISPLAY;
	task.state		= TASK_STAT_FREE;
	task.TaskTime	= 0;
	task.run 		= display_main_run;
	task.sleep_init = display_peripheral_sleep;
	task.msg_process= display_message_process;
	task.task_tick 	= display_task_tick;
	task.is_used 	= 1;
	task.task_init 	= display_variable_init;
	sys_task_add(&task);
}

